package com.coder.shop.mq.listener;

import javax.jms.Destination;

import org.springframework.jms.core.JmsTemplate;

import com.coder.shop.dao.model.BaseMsgCode;

public class MsgCodeSender {

	private final JmsTemplate jmsTemplate;
	private final Destination destination;

	public MsgCodeSender(final JmsTemplate jmsTemplate, final Destination destination) {        
        this.jmsTemplate = jmsTemplate;        
        this.destination = destination;
    }

	public void send(final BaseMsgCode code) {
		try {
			jmsTemplate.setDefaultDestination(destination);
			jmsTemplate.convertAndSend(code);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
